---
category: Level 1 — Basic
created: '2020-02-17'
keywords: get element HTML, HTML of element, innerHTML, set element HTML
title: Get or set the HTML of an element
---

## Get the HTML

```js
// Get the HTML
const html = ele.innerHTML;
```

## Set the HTML

```js
// Set the HTML
ele.innerHTML = '<h1>Hello World!</h1>';
```

## See also

-   [Count the number of characters of a textarea](https://phuoc.ng/collection/html-dom/count-the-number-of-characters-of-a-textarea/)
-   [Detect if the caps lock is on](https://phuoc.ng/collection/html-dom/detect-if-the-caps-lock-is-on/)
-   [Get size of the selected file](https://phuoc.ng/collection/html-dom/get-size-of-the-selected-file/)
-   [Get the text content of an element](https://phuoc.ng/collection/html-dom/get-the-text-content-of-an-element/)
-   [Placeholder for a contenteditable element](https://phuoc.ng/collection/html-dom/placeholder-for-a-contenteditable-element/)
-   [Sort a table by clicking its headers](https://phuoc.ng/collection/html-dom/sort-a-table-by-clicking-its-headers/)
-   [Strip html from a given text](https://phuoc.ng/collection/html-dom/strip-html-from-a-given-text/)
